var t = require("../../../../../ec-canvas/echarts"), e = getApp();

Component({
    properties: {
        history: {
            type: Array,
            value: []
        }
    },
    data: {
        eChartData: [],
        defaultData: [ {
            date: "",
            total: 0,
            people_total: 0
        }, {
            date: "",
            total: 0,
            people_total: 0
        }, {
            date: "",
            total: 0,
            people_total: 0
        } ],
        ecIncome: {
            lazyLoad: !1
        },
        income_dynamic: {
            total_amount: 50
        }
    },
    lifetimes: {
        attached: function() {
            var t = this;
            setTimeout(function() {
                t.getData();
            }, 1e3);
        }
    },
    methods: {
        getData: function() {
            var t = this, a = e.getNetAddresss("finance.income-page.income-charts");
            e._getNetWork({
                url: a,
                data: {
                    charts_type: 0
                },
                success: function(e) {
                    var a = e.data;
                    1 == a.result ? (t.setData({
                        income_dynamic: a.data
                    }), t.setECharts()) : wx.showToast({
                        title: a.msg,
                        icon: "none",
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        setECharts: function() {
            var e = this.selectComponent("#echats-income"), a = {
                title: {
                    text: "历史数据",
                    top: "6%",
                    left: "5%",
                    textStyle: {
                        color: "#0a0a14",
                        fontWeight: "bold"
                    }
                },
                legend: {
                    type: "plain",
                    orient: "horizontal",
                    top: "6%",
                    right: "5%"
                },
                grid: {
                    top: "25%",
                    left: "5%",
                    right: "5%",
                    bottom: "5%",
                    containLabel: !0
                },
                toolbox: {
                    feature: {
                        dataView: {
                            show: !0,
                            readOnly: !1
                        },
                        restore: {
                            show: !0
                        },
                        saveAsImage: {
                            show: !0
                        }
                    }
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "cross",
                        label: {
                            backgroundColor: "#6a7985"
                        }
                    }
                },
                xAxis: {
                    type: "category",
                    axisTick: {
                        show: !1
                    },
                    axisLine: {
                        onZero: !1,
                        lineStyle: {
                            color: "rgb(208,208,208)",
                            width: 2
                        }
                    },
                    axisLabel: {
                        color: "rgb(108,108,108)"
                    }
                },
                yAxis: [ {
                    type: "value",
                    minInterval: 1,
                    axisLine: {
                        show: !1
                    },
                    axisTick: {
                        show: !1
                    },
                    splitLine: {
                        lineStyle: {
                            type: "dashed"
                        }
                    }
                } ],
                series: [ {
                    name: "次数",
                    type: "line",
                    symbol: "circle",
                    symbolSize: 8,
                    barWidth: 25,
                    color: "#34c758"
                }, {
                    name: "人数",
                    type: "line",
                    symbol: "circle",
                    symbolSize: 8,
                    barWidth: 25,
                    color: "#ff9502"
                } ]
            }, o = new Date(), i = new Date(o.getTime() - 864e5), s = new Date(o.getTime() + 864e5);
            this.data.defaultData[0].date = this.dateFormat("mm-dd", i), this.data.defaultData[1].date = this.dateFormat("mm-dd", o), 
            this.data.defaultData[2].date = this.dateFormat("mm-dd", s), this.data.history && this.data.history.length > 0 ? this.data.eChartData = this.data.history : this.data.eChartData = this.data.defaultData, 
            a.dataset = {}, a.dataset.dimensions = [ "date", "total", "people_total" ], a.dataset.source = this.data.eChartData, 
            e.init(function(e, o, i) {
                var s = t.init(e, null, {
                    width: o,
                    height: i
                });
                return s.setOption(a), s;
            });
        },
        initOptions: function() {
            return {
                title: {
                    text: "历史数据",
                    top: "6%",
                    left: "5%",
                    textStyle: {
                        color: "#0a0a14",
                        fontWeight: "bold"
                    }
                },
                legend: {
                    type: "plain",
                    orient: "horizontal",
                    top: "6%",
                    right: "5%"
                },
                grid: {
                    top: "25%",
                    left: "5%",
                    right: "5%",
                    bottom: "5%",
                    containLabel: !0
                },
                toolbox: {
                    feature: {
                        dataView: {
                            show: !0,
                            readOnly: !1
                        },
                        restore: {
                            show: !0
                        },
                        saveAsImage: {
                            show: !0
                        }
                    }
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "cross",
                        label: {
                            backgroundColor: "#6a7985"
                        }
                    }
                },
                xAxis: {
                    type: "category",
                    axisTick: {
                        show: !1
                    },
                    axisLine: {
                        onZero: !1,
                        lineStyle: {
                            color: "rgb(208,208,208)",
                            width: 2
                        }
                    },
                    axisLabel: {
                        color: "rgb(108,108,108)"
                    }
                },
                yAxis: [ {
                    type: "value",
                    minInterval: 1,
                    axisLine: {
                        show: !1
                    },
                    axisTick: {
                        show: !1
                    },
                    splitLine: {
                        lineStyle: {
                            type: "dashed"
                        }
                    }
                } ],
                dataset: {},
                series: [ {
                    name: "次数",
                    type: "line",
                    symbol: "circle",
                    symbolSize: 8,
                    barWidth: 25,
                    color: "#34c758"
                }, {
                    name: "人数",
                    type: "line",
                    symbol: "circle",
                    symbolSize: 8,
                    barWidth: 25,
                    color: "#ff9502"
                } ]
            };
        },
        dateFormat: function(t, e) {
            var a, o = {
                "Y+": e.getFullYear().toString(),
                "m+": (e.getMonth() + 1).toString(),
                "d+": e.getDate().toString(),
                "H+": e.getHours().toString(),
                "M+": e.getMinutes().toString(),
                "S+": e.getSeconds().toString()
            };
            for (var i in o) (a = new RegExp("(" + i + ")").exec(t)) && (t = t.replace(a[1], 1 == a[1].length ? o[i] : o[i].padStart(a[1].length, "0")));
            return t;
        }
    }
});